#include<iostream>
#include<set>
#include<map>
#include<list>
#include<string>
#include<vector>
#include<sstream>
#include<algorithm> 
#include<utility>
#include<fstream>
#include<sstream>
#include"TestSalesData.cpp"
using namespace std;
void practice_11_7();
void practice_11_8();
void practice_11_9();
bool compareIsbn(const Sales_data &lhs,const Sales_data &rhs);
void practice_11_11();
void practice_11_12();
void practice_11_14();
int main()
{
	//practice_11_7();
	//practice_11_8();
	//practice_11_9();
	//practice_11_11();
	//practice_11_12();
	practice_11_14();
	return 0;
}
void practice_11_7()
{
	map<string,vector<string>> member;
	string line,first,second;
	vector<string> v;
	while(getline(cin,line))
		v.push_back(line);
	for(const string &s:v){
		istringstream iss(s);
		iss>>first>>second;
		vector<string> &v=member[first];
		v.push_back(second);
	}
	for(const pair<string,vector<string>> &p:member)
	{
		cout<<p.first<<":"<<endl;
		for(auto v:p.second)
			cout<<v<<" ";
		cout<<endl;
	}
}
void practice_11_8()
{
	vector<int> v{1,2,3,4,2,2,3,4};
	sort(v.begin(),v.end());
	auto end_unique=unique(v.begin(),v.end());
	v.erase(end_unique,v.end());
	for(const auto &i:v)
		cout<<i<<" ";
}
void practice_11_9()
{
	map<string,list<int>> word_line;
}
bool compareIsbn(const Sales_data &lhs,const Sales_data &rhs)
{
	return lhs.isbn()<rhs.isbn();
}
void practice_11_11()
{
	bool(*pc)(const Sales_data &lhs,const Sales_data &rhs);
	pc=&compareIsbn;
	multiset<Sales_data,bool(*)(const Sales_data &lhs,const Sales_data &rhs)>bookstore(pc);
}
void practice_11_12()
{
	string line,word,score;
	ifstream input("Items.txt");
	vector<pair<string,int>> v;
	while(getline(input,line))
	{
		istringstream ss(line);
		ss>>word>>score;
		int s=stoi(score);
		v.push_back(make_pair(word,s));
	}
	for(auto &p:v)
		cout<<p.first<<" "<<p.second<<endl;
}
void practice_11_14()
{
	map<string,vector<pair<string,string>>> member;
	string line,first,second,date;
	vector<string> v;
	ifstream input("Members.txt");
	while(getline(input,line))
		v.push_back(line);
	for(const string &s:v){
		istringstream iss(s);
		iss>>first>>second>>date;
		vector<pair<string,string>> &v=member[first];
		v.push_back(make_pair(second,date));
	}
	for(const pair<string,vector<pair<string,string>>> &p:member)
	{
		cout<<p.first<<":"<<endl;
		for(auto v:p.second)
			cout<<v.first<<" "<<v.second<<" ";
		cout<<endl;
	}
}